negotiator.protocol.alternatingoffers
Class AlternatingOffersProtocol

java.lang.Object
  extended by negotiator.protocol.Protocol
      extended by negotiator.protocol.alternatingoffers.AlternatingOffersProtocol
All Implemented Interfaces:
java.io.Serializable, java.lang.Runnable

public class AlternatingOffersProtocol
extends Protocol

Manager of the Alternating Offers protocol: Loads and initializes agents, domain, etc. Signals the start/stop of negotiations by calling BilateralAtomicNegotiationSession. Manages time-outs.

See Also:
Serialized Form

Field Summary
protected  Agent agentA
           
protected  Agent agentB
           
static int ALTERNATING_OFFERS_AGENT_A_INDEX
           
static int ALTERNATING_OFFERS_AGENT_B_INDEX
           
protected  java.lang.String startingAgent
           
 
Fields inherited from class negotiator.protocol.Protocol
domain, negoThread, sessionNr, stopNegotiation, totalSessions, tournamentRunner
 
Constructor Summary
AlternatingOffersProtocol(AgentRepItem[] agentRepItems, ProfileRepItem[] profileRepItems, java.util.HashMap<AgentParameterVariable,AgentParamValue>[] agentParams, int totalSessionRounds)
          RUN A NEGO SESSION.
 
Method Summary
 void addNegotiationPaths(int sessionNumber, java.util.ArrayList<BidPoint> pAgentABids, java.util.ArrayList<BidPoint> pAgentBBids)
          Call this method to draw the negotiation paths on the chart with analysis.
protected static java.util.ArrayList<AlternatingOffersProtocol> allParameterCombis(Tournament tournament, AgentRepItem agentA, AgentRepItem agentB, ProfileRepItem profileA, ProfileRepItem profileB)
          This is a recursive function that iterates over all *parameters* and tries all values for each, recursively calling itself to iterate over the remaining parameters.
protected static void allParameterCombis(Tournament tournament, java.util.ArrayList<AssignedParameterVariable> allparameters, java.util.ArrayList<AlternatingOffersProtocol> sessions, ProfileRepItem profileA, ProfileRepItem profileB, AgentRepItem agentA, AgentRepItem agentB, java.util.ArrayList<AssignedParamValue> chosenvalues)
          adds all permutations of all NegotiationSessions to the given sessions array.
static void closeLog(boolean extensive)
           
 void createExtraLogData()
          Append quality measure information to the additional outcome field.
 Agent getAgent(int index)
           
 java.lang.String getAgentAname()
           
 java.util.HashMap<AgentParameterVariable,AgentParamValue> getAgentAparams()
           
 AgentRepItem getAgentARep()
           
 java.lang.String getAgentAStrategyName()
           
 UtilitySpace getAgentAUtilitySpace()
           
 java.lang.String getAgentBname()
           
 java.util.HashMap<AgentParameterVariable,AgentParamValue> getAgentBparams()
           
 AgentRepItem getAgentBRep()
           
 java.lang.String getAgentBStrategyName()
           
 UtilitySpace getAgentBUtilitySpace()
           
 Domain getDomain()
           
 java.lang.String getName()
           
 NegotiationOutcome getNegotiationOutcome()
           
 java.lang.String getOutcome()
           
 ProfileRepItem getProfileArep()
           
 ProfileRepItem getProfileBrep()
           
 AlternatingOffersBilateralAtomicNegoSession getSessionRunner()
           
 java.lang.String getStartingAgent()
           
 java.lang.Integer getTotalTime()
           
static java.util.ArrayList<Protocol> getTournamentSessions(Tournament tournament)
          Called when you press start button in Tournament window via reflection in TournamentRunner.
static java.util.ArrayList<Protocol> getTournamentSessions(Tournament tournament, boolean selfplay, boolean both_sides)
           
protected  AlternatingOffersBilateralAtomicNegoSession newAlternatingOffersBilateralAtomicNegoSession()
           
 void run()
          Warning.
protected  void runNegotiationSession()
          Run a negotiation session.
 void startNegotiation()
          this runs sessionTotalNumber of sessions with the provided settings
 void stopNegotiation()
           
 java.lang.String toString()
           
 
Methods inherited from class negotiator.protocol.Protocol
addNegotiationEventListener, fireBilateralAtomicNegotiationSessionEvent, fireLogMessage, fireNegotiationActionEvent, getAgentName, getAgentParams, getAgentRepItem, getAgentUtilitySpaces, getNegotiationEventListeners, getNumberOfAgents, getProfileRepItems, getSessionNumber, getTotalSessions, hashCode, loadAgentsUtilitySpaces, removeNegotiationEventListener, setTournamentRunner, startSession
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ALTERNATING_OFFERS_AGENT_A_INDEX

public static final int ALTERNATING_OFFERS_AGENT_A_INDEX
See Also:
Constant Field Values

ALTERNATING_OFFERS_AGENT_B_INDEX

public static final int ALTERNATING_OFFERS_AGENT_B_INDEX
See Also:
Constant Field Values

startingAgent

protected java.lang.String startingAgent

agentA

protected Agent agentA

agentB

protected Agent agentB
Constructor Detail

AlternatingOffersProtocol

public AlternatingOffersProtocol(AgentRepItem[] agentRepItems,
                                 ProfileRepItem[] profileRepItems,
                                 java.util.HashMap<AgentParameterVariable,AgentParamValue>[] agentParams,
                                 int totalSessionRounds)
                          throws java.lang.Exception
RUN A NEGO SESSION. code below comes from NegotiationManager

Throws:
java.lang.Exception
Method Detail

run

public void run()
Warning. You can call run() directly (instead of using Thread.start() ) but be aware that run() will not return until the nego session has completed. That means that your interface will lock up until the session is complete. And if the negosession uses modal interfaces, this will lock up swing, because modal interfaces will not launch until the other swing interfaces have handled their events. (at least this is my current understanding, Wouter, 22aug08). See "java dialog deadlock" on the web...


startNegotiation

public void startNegotiation()
                      throws java.lang.Exception
this runs sessionTotalNumber of sessions with the provided settings

Throws:
java.lang.Exception

runNegotiationSession

protected void runNegotiationSession()
                              throws java.lang.Exception
Run a negotiation session. There may be multiple test runs of a single session, for instance to take the average score. returns the result in the global field "outcome"

Parameters:
nr - is the sessionTestNumber
Throws:
java.lang.Exception

createExtraLogData

public void createExtraLogData()
Append quality measure information to the additional outcome field.


newAlternatingOffersBilateralAtomicNegoSession

protected AlternatingOffersBilateralAtomicNegoSession newAlternatingOffersBilateralAtomicNegoSession()
                                                                                              throws java.lang.Exception
Throws:
java.lang.Exception

closeLog

public static void closeLog(boolean extensive)

stopNegotiation

public void stopNegotiation()
Overrides:
stopNegotiation in class Protocol

toString

public java.lang.String toString()
Overrides:
toString in class Protocol

getOutcome

public java.lang.String getOutcome()

addNegotiationPaths

public void addNegotiationPaths(int sessionNumber,
                                java.util.ArrayList<BidPoint> pAgentABids,
                                java.util.ArrayList<BidPoint> pAgentBBids)
Call this method to draw the negotiation paths on the chart with analysis. Wouter: moved to here from Analysis.

Parameters:
pAgentABids -
pAgentBBids -

getDomain

public Domain getDomain()
Overrides:
getDomain in class Protocol

getAgentAUtilitySpace

public UtilitySpace getAgentAUtilitySpace()

getAgentBUtilitySpace

public UtilitySpace getAgentBUtilitySpace()

getAgentAname

public java.lang.String getAgentAname()

getAgentBname

public java.lang.String getAgentBname()

getAgentAparams

public java.util.HashMap<AgentParameterVariable,AgentParamValue> getAgentAparams()

getAgentBparams

public java.util.HashMap<AgentParameterVariable,AgentParamValue> getAgentBparams()

getProfileArep

public ProfileRepItem getProfileArep()

getProfileBrep

public ProfileRepItem getProfileBrep()

getAgentARep

public AgentRepItem getAgentARep()

getAgentBRep

public AgentRepItem getAgentBRep()

getAgentAStrategyName

public java.lang.String getAgentAStrategyName()

getAgentBStrategyName

public java.lang.String getAgentBStrategyName()

getTotalTime

public java.lang.Integer getTotalTime()
Returns:
total available time for entire nego, in seconds.

getStartingAgent

public java.lang.String getStartingAgent()

getSessionRunner

public AlternatingOffersBilateralAtomicNegoSession getSessionRunner()

getName

public java.lang.String getName()
Specified by:
getName in class Protocol

getNegotiationOutcome

public NegotiationOutcome getNegotiationOutcome()
Specified by:
getNegotiationOutcome in class Protocol

getAgent

public Agent getAgent(int index)

getTournamentSessions

public static java.util.ArrayList<Protocol> getTournamentSessions(Tournament tournament)
                                                           throws java.lang.Exception
Called when you press start button in Tournament window via reflection in TournamentRunner. This builds the sessions array from given Tournament vars The procedure skips sessions where both sides use the same preference profiles.

Throws:
exception - if something wrong with the variables, eg not set.
java.lang.Exception

getTournamentSessions

public static java.util.ArrayList<Protocol> getTournamentSessions(Tournament tournament,
                                                                  boolean selfplay,
                                                                  boolean both_sides)
                                                           throws java.lang.Exception
Throws:
java.lang.Exception

allParameterCombis

protected static java.util.ArrayList<AlternatingOffersProtocol> allParameterCombis(Tournament tournament,
                                                                                   AgentRepItem agentA,
                                                                                   AgentRepItem agentB,
                                                                                   ProfileRepItem profileA,
                                                                                   ProfileRepItem profileB)
                                                                            throws java.lang.Exception
This is a recursive function that iterates over all *parameters* and tries all values for each, recursively calling itself to iterate over the remaining parameters. This only runs over parameters, not the other variables (Agents and Profiles) because there may be many parameters and we need to filter Not all permutations of the vars are acceptable, for instance domains have to be idnetical. One optimization:

Parameters:
sessions - is the final result: all valid permutations of variables.
varnr - is the index of the variable in the variables array.
Throws:
exception - if one of the variables contains no values (which would prevent any running sessions to be created with that variable.
java.lang.Exception

allParameterCombis

protected static void allParameterCombis(Tournament tournament,
                                         java.util.ArrayList<AssignedParameterVariable> allparameters,
                                         java.util.ArrayList<AlternatingOffersProtocol> sessions,
                                         ProfileRepItem profileA,
                                         ProfileRepItem profileB,
                                         AgentRepItem agentA,
                                         AgentRepItem agentB,
                                         java.util.ArrayList<AssignedParamValue> chosenvalues)
                                  throws java.lang.Exception
adds all permutations of all NegotiationSessions to the given sessions array. Note, this is not threadsafe, if called from multiple threads the session number will screw up.

Parameters:
allparameters - the parameters of the agents that were selected for this nego session.
sessions -
Throws:
java.lang.Exception